home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / include / linux / pmic_status.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-09  |  2.5 KB  |  83 lines

  1. /*
  2.  * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
  3.  */
  4.  
  5. /*
  6.  * The code contained herein is licensed under the GNU Lesser General
  7.  * Public License.  You may obtain a copy of the GNU Lesser General
  8.  * Public License Version 2.1 or later at the following locations:
  9.  *
  10.  * http://www.opensource.org/licenses/lgpl-license.html
  11.  * http://www.gnu.org/copyleft/lgpl.html
  12.  */
  13. #ifndef __ASM_ARCH_MXC_PMIC_STATUS_H__
  14. #define __ASM_ARCH_MXC_PMIC_STATUS_H__
  15. #include <asm-generic/errno-base.h>
  16. #ifdef __KERNEL__
  17. #include <asm/uaccess.h>    /* copy_{from,to}_user() */
  18. #endif
  19. /*!
  20.  * @file arch-mxc/pmic_status.h
  21.  * @brief PMIC APIs return code definition.
  22.  *
  23.  * @ingroup PMIC_CORE
  24.  */
  25.  
  26. /*!
  27.  * @enum PMIC_STATUS
  28.  * @brief Define return values for all PMIC APIs.
  29.  *
  30.  * These return values are used by all of the PMIC APIs.
  31.  *
  32.  * @ingroup PMIC
  33.  */
  34. typedef enum {
  35.     PMIC_SUCCESS = 0,    /*!< The requested operation was successfully
  36.                    completed.                                     */
  37.     PMIC_ERROR = -1,    /*!< The requested operation could not be completed
  38.                    due to an error.                               */
  39.     PMIC_PARAMETER_ERROR = -2,    /*!< The requested operation failed because
  40.                        one or more of the parameters was
  41.                        invalid.                             */
  42.     PMIC_NOT_SUPPORTED = -3,    /*!< The requested operation could not be
  43.                        completed because the PMIC hardware
  44.                        does not support it. */
  45.     PMIC_SYSTEM_ERROR_EINTR = -EINTR,
  46.  
  47.     PMIC_MALLOC_ERROR = -5,    /*!< Error in malloc function             */
  48.     PMIC_UNSUBSCRIBE_ERROR = -6,    /*!< Error in un-subscribe event          */
  49.     PMIC_EVENT_NOT_SUBSCRIBED = -7,    /*!< Event occur and not subscribed       */
  50.     PMIC_EVENT_CALL_BACK = -8,    /*!< Error - bad call back                */
  51.     PMIC_CLIENT_NBOVERFLOW = -9,    /*!< The requested operation could not be
  52.                        completed because there are too many
  53.                        PMIC client requests */
  54. } PMIC_STATUS;
  55.  
  56. /*
  57.  * Bitfield macros that use rely on bitfield width/shift information.
  58.  */
  59. #define BITFMASK(field) (((1U << (field ## _WID)) - 1) << (field ## _LSH))
  60. #define BITFVAL(field, val) ((val) << (field ## _LSH))
  61. #define BITFEXT(var, bit) ((var & BITFMASK(bit)) >> (bit ## _LSH))
  62.  
  63. /*
  64.  * Macros implementing error handling
  65.  */
  66. #define CHECK_ERROR(a)            \
  67. do {                    \
  68.         int ret = (a);             \
  69.         if (ret != PMIC_SUCCESS)    \
  70.     return ret;             \
  71. } while (0)
  72.  
  73. #define CHECK_ERROR_KFREE(func, freeptrs) \
  74. do { \
  75.     int ret = (func); \
  76.     if (ret != PMIC_SUCCESS) { \
  77.         freeptrs;    \
  78.         return ret;    \
  79.     }    \
  80. } while (0);
  81.  
  82. #endif                /* __ASM_ARCH_MXC_PMIC_STATUS_H__ */
  83.